package com.apes.framework.plugin.esb.processor;

import com.apes.framework.plugin.esb.api.Request;
import com.apes.framework.util.EventUtil;
import com.apes.framework.util.MapUtil;

//import com.apes.framework.plugin.mq.MQUtil;

/**
 * 功能：消息生产者处理器类
 *
 * @author xul
 * @create 2017-12-07 17:30
 */
public class ProducerProcessor<T extends Request, R> extends AbstractChainProcessor<T, R> {

    private String topic;
    private String description;

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    protected R doProcess(T data) {
        //MQUtil.publish(topic, description, data.getData());
        EventUtil.sendAynEvent(this, "event:mq.publish",
                MapUtil.mapper("topic", topic, "description", description, "body", data.getData()));
        return null;
    }

}
